export default {
  namespaced: true,
  state: () => {
    return {
      address: JSON.parse(uni.getStorageSync('address') || '{}'),
    }
  },

  mutations: {
    updateAdress(state, adress) {
      state.address = adress
    },

    // 定义将 address 持久化存储到本地 mutations 方法
    saveAddressToStorage(state) {
      uni.setStorageSync('adress', JSON.stringify(state.address))
    }
  },

  getters: {
    // 收货详细地址的计算属性
    addstr(state) {
      if (!state.address.provinceName) return "";

      // 拼接 省，市，区，详细地址 的字符串并返回给用户
      return (
        state.address.provinceName +
        state.address.cityName +
        state.address.countyName +
        state.address.detailInfo
      );
    },

    

  }
}